package jtacck.labmedicine;

import android.app.ProgressDialog;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.Toast;

/**
 * Customized tab activity for displaying routing information and a map.
 * 
 * @see android.app.TabActivity
 * 
 * @author Andrew
 * 
 */
public class RouteMapTabActivity extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        /** Removes the title of the window **/
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        /** Set view to tabbed layout **/
        setContentView(R.layout.tabbed_layout);

        Intent intent;
        TabHost.TabSpec spec;

        /** Retrieve reference to resources and tab host **/
        Resources res = getResources();
        TabHost tabHost = getTabHost();     

        /** Create an Intent to launch an Activity for the tab **/
        intent = new Intent().setClass(this, RouteListActivity.class);

        /** Initialize a TabSpec for each tab and add it to the TabHost **/
        spec = tabHost
                .newTabSpec("route")
                .setIndicator("Route",
                        res.getDrawable(R.drawable.icon_tab_route))
                .setContent(intent);
        tabHost.addTab(spec);

        /** Reuse other intent for another activity **/
        intent = new Intent().setClass(this, GoogleMapActivity.class);
        
        /** Same as above **/
        spec = tabHost.newTabSpec("map")
                .setIndicator("Map", res.getDrawable(R.drawable.maps_icon))
                .setContent(intent);
        tabHost.addTab(spec);
        
        /*getTabWidget().getChildAt(1).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                ProgressDialog.show(RouteMapTabActivity.this, "", "Retrieving data...", true, true);
                getTabHost().setCurrentTab(1);
            }
            
        });*/

        /** Set default tab **/
        tabHost.setCurrentTab(0);
    }

}